﻿using System.Collections.Generic;
using AutoClub.Core.Dao.Implementations;
using AutoClub.Core.Domain;
using AutoClub.Core.Domain.Dao;
using FluentAssertions;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace AutoClub.Core.Tests
{
    /// <summary>
    /// Summary description for UserRolesRepoTests
    /// </summary>
    [TestClass]
    public class UserRolesRepoTests : BaseRepoTest
    {
        #region Fields

        IUserRolesRepo myRepoToTest;

        #endregion

        [TestInitialize()]
        public override void MyTestInitialize()
        {
            base.MyTestInitialize();
            myRepoToTest = new UserRolesRepo(this.uof);
        }

        /// <summary>
        /// Tests the Get All method when there is no user roles in the database
        /// </summary>
        [TestMethod, TestCategory("Integration")]
        public void TestGetAllWhenThereIsNoData()
        {
            //Setup

            //SUT
            IEnumerable<UserRol> result = this.myRepoToTest.GetAll();

            //Asserts
            result.Should().NotBeNull("Expected an enumerable of users");
            result.Should().HaveCount(3, "Expected 3 elements in the result set");
        }

        /// <summary>
        /// Tests the Get by Method when there are a few users to retrieve
        /// </summary>
        [TestMethod, TestCategory("Integration")]
        public void TestGetByMethod()
        {

            //SUT
            IEnumerable<UserRol> result = this.myRepoToTest.GetBy(b => b.Value == UserRolEnum.Administrator);

            //Asserts
            result.Should().NotBeNull("Expected a enumerable of user roles to retrieve");
            result.Should().NotBeEmpty("Expected 1 user rol enum");
        }

        /// <summary>
        /// Tests the Get by Id Method when there is a single user rol to retrieve
        /// </summary>
        [TestMethod, TestCategory("Integration")]
        public void TestGetMethod()
        {

            //SUT
            UserRol result = this.myRepoToTest.Get(UserRolEnum.Pilot);

            //Asserts
            result.Should().NotBeNull("Expected a user rol retrieve it");
            result.Value.Should().Be(UserRolEnum.Pilot, "Wrong user rol enum");
        }
    }
}
